Operations and Objects in R
Quarto Notebooks, Operations and Objects
Bogdan G. Popescu
John Cabot University
What You’ll Learn Today
Getting Started with Quarto and R
Basic R Operations and Syntax
Understanding Objects in R: numeric, character, logical objects
Working with Data Structures: vectors, matrices, dataframes
Exploring and Cleaning Data
By the end, you’ll be able to write simple R scripts and explore your own data.
Using R
Let us now use R to understand how it works.
Let’s create a new quarto document and save it in your “week2” folder.
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Press CMD + A or Ctrl + A and then Press Delete
Using R
Using R
Then type:
---
title : "Notebook"
author : "Your Name"
date : "July 26, 2025"
format :
html :
toc : true
number-sections : true
colorlinks : true
smooth-scroll : true
embed-resources : true
---
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
R can be used as a simple calculator and we can perform any simple computation.
Using R
R can be used as a simple calculator and we can perform any simple computation.
Using R
R can be used as a simple calculator and we can perform any simple computation.
# Sample Session
# This is a comment
Using R
R can be used as a simple calculator and we can perform any simple computation.
# Sample Session
# This is a comment
# print a number
2
Using R
R can be used as a simple calculator and we can perform any simple computation.
Using R
R can be used as a simple calculator and we can perform any simple computation.
Using R
R can be used as a simple calculator and we can perform any simple computation.
Using R
R can be used as a simple calculator and we can perform any simple computation.
# Sample Session
# This is a comment
# print a number
2
Using R
R can be used as a simple calculator and we can perform any simple computation.
# Sample Session
# This is a comment
# print a number
2
# perform a simple calculation
2 + 3
Using R
R can be used as a simple calculator and we can perform any simple computation.
# Sample Session
# This is a comment
# print a number
2
# perform a simple calculation
2 + 3
After we type 2+3 and press Enter , 2+3 is sent to your computer’s processor.
Using R
R can be used as a simple calculator and we can perform any simple computation.
# Sample Session
# This is a comment
# print a number
2
# perform a simple calculation
2 + 3
After we type 2+3 and press Enter , 2+3 is sent to your computer’s processor.
The returned value 5 is then printed in the console
Using R
R can be used as a simple calculator and we can perform any simple computation.
# Sample Session
# This is a comment
# print a number
2
# perform a simple calculation
2 + 3
After we type 2+3 and press Enter , 2+3 is sent to your computer’s processor.
The returned value 5 is then printed in the console
Note that this is not kept in memory.
Using R
R can be used as a simple calculator and we can perform any simple computation.
# Sample Session
# This is a comment
# print a number
2
# perform a simple calculation
2 + 3
After we type 2+3 and press Enter , 2+3 is sent to your computer’s processor.
The returned value 5 is then printed in the console
Note that this is not kept in the RAM memory: 5 is simply printed in the console.
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
Using R
This is what the output looks like in your working directory.
Numeric and string objects
# store a numeric object
x <- 2
Numeric and string objects
Numeric and string objects
Numeric and string objects
# store a numeric object
x <- 2
# print this numeric object
x
Numeric and string objects
# store a numeric object
x <- 2
# print this numeric object
x
# store a string object
x <- "Hello"
Numeric and string objects
# store a numeric object
x <- 2
# print this numeric object
x
# store a string object
x <- "Hello"
x
Numeric and string objects
Numeric and string objects
Numeric and string objects
# store a numeric object
x <- 2
# print this numeric object
x
# store a string object
x <- "Hello"
x
# we can also write
x <- 'Hello'
x
Numeric and string objects
# store a numeric object
x <- 2
# print this numeric object
x
# store a string object
x <- "Hello"
x
# we can also write
x <- 'Hello'
x
Note that when x is 1 or 3, we say that x is a numeric object
Numeric and string objects
# store a numeric object
x <- 2
# print this numeric object
x
# store a string object
x <- "Hello"
x
# we can also write
x <- 'Hello'
x
Note that when x is 1 or 3, we say that x is a numeric object
When x is "Hello" or 'Hello', we say that x is a string object .
Arithmetic operations
+
Addition
-
Subtraction
*
Multiplication
/
Division
^
Exponent
Arithmetic operations
Here are examples of this:
Arithmetic operations
Here are examples of this:
Arithmetic operations
Here are examples of this:
Arithmetic operations
Here are examples of this:
Arithmetic operations
Here are examples of this:
Spot the Difference
Here are examples of this:
Spot the Difference
Spot the Difference
Spot the Difference
# Addition
addition <- 5 + 3
# Subtraction
subtraction <- 4-5
# Multiplication
multiplication <- 2 * 3
# Division
division <- 3 / 3
# Exponent
exponent <- 5 ^ 2
Spot the Difference
Spot the Difference
Arithmetic operations
Note that numbers that are either very large or very small , R uses scientific notation
Note that 1000000 has 6 zeros.
This can also be written as \(1*10^{-6}\) or \((\frac{1}{10})^6\)
Thus, the output produced by R - 1e-06 makes sense.
Arithmetic operations
Infinity is treated as a special type of number: Inf or -Inf.
This results in Inf: division by zero is undefined
In the limit, as a number approaches zero, its reciprocal becomes larger and larger, eventually reaching infinity.
Conditional Operators
Conditions are expressions that use conditional operators and that have TRUE or FALSE as a result
The conditional operators available in R are listed below:
==
Equal
>
Greater than
>=
Greater than or equal
<
Less than
<=
Less than or equal
!=
Not equal
&, |
And, Or
Conditional Operators Examples
We can use conditional operators in the following examples:
Conditional Operators Examples
Or
Special Values
Inf
Infinity
NA
Not Available
NaN
Not a Number
NULL
Empty object
Classes
R is an object-oriented language where each object belongs to a class
The class function accepts an object and returns a class name
Vectors
The vector is the simplest data structure in R.
Vectors
The vector is the simplest data structure in R.
It is an ordered collection of values of the same type:
Vectors
The vector is the simplest data structure in R.
It is an ordered collection of values of the same type:
Numbers - numeric (numbers with a decimal point) or integer (whole numbers)
Text - character
Logical - logical
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
# Storing a numeric vector
vector1 <- 600
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
# Storing a numeric vector
vector1 <- 600
vector1
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
# Storing a numeric vector
vector1 <- 600
length (vector1)
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
# Storing another character vector
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
# Storing another character vector
vector2 <- "Hello"
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
# Storing another character vector
vector2 <- "Hello"
vector2
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
# Storing another character vector
vector2 <- "Hello"
length (vector2)
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
# Storing another logical vector
vector3 <- TRUE
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
# Storing another logical vector
vector3 <- TRUE
vector3
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
Vectors of length 1
A vector of length 1 can be created by typing 600, "Hello" or TRUE.
# Storing another logical vector
vector3 <- TRUE
length (vector3)
Vectors
A vector of length > 1 can be achieved by using the c function with various inputs
Vectors
A vector of length > 1 can be achieved by using the c function with various inputs
For example we can create a vector of length 2
Vectors
A vector of length > 1 can be achieved by using the c function with various inputs
For example we can create a vector of length 2
# Storing a vector of length 2
The c function
A vector of length > 1 can be achieved by using the c function with various inputs
For example we can create a vector of length 2
# Storing a vector of length 2
vector4 <- c (1 , 2 )
The c function
A vector of length > 1 can be achieved by using the c function with various inputs
For example we can create a vector of length 2
# Storing a vector of length 2
vector4 <- c (1 , 2 )
vector4
The c function
A vector of length > 1 can be achieved by using the c function with various inputs
The c function
A vector of length > 1 can be achieved by using the c function with various inputs
The c function
A vector of length > 1 can be achieved by using the c function with various inputs
For example we can create a vector of length 2
# Storing a vector of length 2
vector4 <- c (1 , 2 )
length (vector4)
Vector Naming Conventions in R
Vector names should be descriptive :
ages, income_levels, country_codes
Use snake_case or camelCase , but be consistent:
average_income (snake_case)
averageIncome (camelCase)
Avoid starting names with numbers or special characters:
❌ 2nd_vector, #income
Avoid reserved words or function names:
❌ mean, sum, data
R is case-sensitive: Income ≠ income
Vectors of different types
We can also create a vector made out of different elements
Vectors of different types
We can also create a vector made out of different elements
# Storing a vector of elements of different types
Vectors of different types
We can also create a vector made out of different elements
# Storing a vector of elements of different types
x <- c (1 , "Hello" )
Vectors of different types
We can also create a vector made out of different elements
# Storing a vector of elements of different types
x <- c (1 , "Hello" )
x
Vectors of different types
We can also create a vector made out of different elements
Vectors of different types
We can also create a vector made out of different elements
Vectors of character elements
We can also create a vector (list) made out of character elements
Vectors of character elements
We can also create a vector (list) made out of character elements
#This is a list
list_fields <- c ("politics" , "philosophy" , "literature" , "chemistry" )
Vectors of character elements
Vectors of character elements
Vectors of character elements
This is how we remove an element from the list
#This is a list
list_fields <- c ("politics" , "philosophy" , "literature" , "chemistry" )
This is how we remove strings from vectors
#This is how we get rid of the element called "politics"
list_fields_new <- list_fields[list_fields != "politics" ]
Vectors of character elements
Notice the length difference
Logical Subsetting
This is how we can do logical subsetting
# Create a numeric vector
list_no <- c (11 , 12 , 13 , 14 , 15 , 16 , 17 )
Logical Subsetting
This is how we can do logical subsetting
# Create a numeric vector
list_no <- c (11 , 12 , 13 , 14 , 15 , 16 , 17 )
# Keep values less than or equal to 13 OR greater than or equal to 15
list_no_filtered <- list_no[list_no <= 13 | list_no >= 15 ]
Logical Subsetting
This is how we can do logical subsetting
# Create a numeric vector
list_no <- c (11 , 12 , 13 , 14 , 15 , 16 , 17 )
# Keep values less than or equal to 13 OR greater than or equal to 15
list_no_filtered <- list_no[list_no <= 13 | list_no >= 15 ]
list_no_filtered
Logical Subsetting
This is how we can do logical subsetting
# Create a numeric vector
list_no <- c (11 , 12 , 13 , 14 , 15 , 16 , 17 )
# Keep values less than or equal to 13 OR greater than or equal to 15
list_no_filtered <- list_no[list_no <= 13 | list_no >= 15 ]
Logical Subsetting
This is how we can do logical subsetting
# Create a numeric vector
list_no <- c (11 , 12 , 13 , 14 , 15 , 16 , 17 )
# Keep values less than or equal to 13 OR greater than or equal to 15
list_no_filtered <- list_no[list_no <= 13 | list_no >= 15 ]
# Printing the second element
list_no[2 ]
Logical Subsetting
This is how we can do logical subsetting
# Create a numeric vector
list_no <- c (11 , 12 , 13 , 14 , 15 , 16 , 17 )
# Keep values less than or equal to 13 OR greater than or equal to 15
list_no_filtered <- list_no[list_no <= 13 | list_no >= 15 ]
# Printing the second, the 3rd, the 4th and 5th component
list_no[2 : 5 ]
Logical Subsetting
This is how we can do logical subsetting with strings
# Create a character vector
list_words <- c ("random" , "word" , "sentence" , "books" )
# List of words to exclude
exclusion_list <- c ("word" , "sentence" , "books" )
# Keep only elements not in the exclusion list
list_words_filtered <- list_words[! (list_words %in% exclusion_list)]
list_words_filtered
Strings & Comparison
This is how we can check which string is “greater” alphabetically and how to count the number of characters in a string
# Check which string is "greater" alphabetically
"four" > "five" # TRUE because "o" comes after "i" in the alphabet
# Count the number of characters in the word
nchar ("four" )
Missing Data
This is how we can handle missing data
# Create a vector with a missing value (NA)
list_no <- c (1 , 2 , 3 , 4 , NA , 5 , 6 )
Missing Data
This is how we can handle missing data
# Create a vector with a missing value (NA)
list_no <- c (1 , 2 , 3 , 4 , NA , 5 , 6 )
# Checking if there is NA
is.na (list_no)
[1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE
Missing Data
This is how we can handle missing data
# Create a vector with a missing value (NA)
list_no <- c (1 , 2 , 3 , 4 , NA , 5 , 6 )
# Checking if there is NA
is.na (list_no)
[1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE
# Remove missing values using !is.na()
list_no_clean <- list_no[! is.na (list_no)]
Missing Data
This is how we can handle missing data
# Create a vector with a missing value (NA)
list_no <- c (1 , 2 , 3 , 4 , NA , 5 , 6 )
# Checking if there is NA
is.na (list_no)
[1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE
# Remove missing values using !is.na()
list_no_clean <- list_no[! is.na (list_no)]
list_no_clean
Basic Operations with Vectors
Here is how we can perform basic mathematical operations with vectors
# This is another vector
weight <- c (88 , 72 , 85 , 52 , 71 , 69 , 61 , 61 , 51 , 75 )
Basic Operations with Vectors
Here is how we can perform basic mathematical operations with vectors
# This is another vector
weight <- c (88 , 72 , 85 , 52 , 71 , 69 , 61 , 61 , 51 , 75 )
# This is another vector
height <- c (168 , 177 , 177 , 177 , 178 , 172 , 165 , 171 , 178 , 170 )
Basic Operations with Vectors
Here is how we can perform basic mathematical operations with vectors
# This is another vector
weight <- c (88 , 72 , 85 , 52 , 71 , 69 , 61 , 61 , 51 , 75 )
# This is another vector
height <- c (168 , 177 , 177 , 177 , 178 , 172 , 165 , 171 , 178 , 170 )
# Performing a simple calculation using vectors
bmi = weight/ ((height/ 100 )^ 2 )
Basic Operations with Vectors
Here is how we can perform basic mathematical operations with vectors
# This is another vector
weight <- c (88 , 72 , 85 , 52 , 71 , 69 , 61 , 61 , 51 , 75 )
# This is another vector
height <- c (168 , 177 , 177 , 177 , 178 , 172 , 165 , 171 , 178 , 170 )
# Performing a simple calculation using vectors
bmi = weight/ ((height/ 100 )^ 2 )
print (bmi)
[1] 31.17914 22.98190 27.13141 16.59804 22.40879 23.32342 22.40588 20.86112
[9] 16.09645 25.95156
Consecutive vectors
Other than the c function there are three additional operations for creating vectors:
The : operator
We can create a vector with consecutive numbers:
The : operator
We can create a vector with consecutive numbers:
The seq function
The seq function gives more flexibility by introducing three additional parameters.
The seq function
The seq function gives more flexibility by introducing three additional parameters.
The seq function
The seq function gives more flexibility by introducing three additional parameters.
from - where to start
to - where to end
The seq function
The seq function gives more flexibility by introducing three additional parameters.
from - where to start
to - where to end
by - step size
The seq function
The seq function gives more flexibility by introducing three additional parameters.
from - where to start
to - where to end
by - step size
x2 <- seq (from = 1 , to = 5 , by = 1 )
The seq function
The seq function gives more flexibility by introducing three additional parameters.
from - where to start
to - where to end
by - step size
x2 <- seq (from = 1 , to = 5 , by = 1 )
x2
The seq function
The seq function gives more flexibility by introducing three additional parameters.
from - where to start
to - where to end
by - step size
x2 <- seq (from = 1 , to = 5 , by = 1 )
x2
x3 <- seq (from = 1 , to = 5 , by = 2 )
x3
Repetitive Vectors
The rep function replicates its argument to create a repetitive vector:
Repetitive Vectors
The rep function replicates its argument to create a repetitive vector:
x - the object to replicate
Repetitive Vectors
The rep function replicates its argument to create a repetitive vector:
x - the object to replicate
times - how many times to replicate the vector
Repetitive Vectors
The rep function replicates its argument to create a repetitive vector:
x - the object to replicate
times - how many times to replicate the vector
each - how many times to replicate each element
Repetitive Vectors
The rep function replicates its argument to create a repetitive vector:
x - the object to replicate
times - how many times to replicate the vector
each - how many times to replicate each element
x4 <- rep (x = 2 , times = 5 )
Repetitive Vectors
The rep function replicates its argument to create a repetitive vector:
x - the object to replicate
times - how many times to replicate the vector
each - how many times to replicate each element
x4 <- rep (x = 2 , times = 5 )
x4
The sort function
The sort function returns ordered vector indices
sort (x, decreasing = FALSE )
The paste and paste0 function
Example:
paste ("There are" , "5" , "books." )
Alternatively:
paste ("There are" , "5" , "books." , sep = "_" )
The paste and paste0 function
We can use paste to obtain names of files
paste ("image" , 1 : 5 , ".tif" , sep = "" )
[1] "image1.tif" "image2.tif" "image3.tif" "image4.tif" "image5.tif"
The paste and paste0 function
paste() is like concatenation using separation factor
paste0() is like append function using separation factor - simply pastes with no separator.
Matrices
Defining vectors:
# This is another vector
weight <- c (88 , 72 , 85 , 52 , 71 , 69 , 61 , 61 , 51 , 75 )
height <- c (168 , 177 , 177 , 177 , 178 , 172 , 165 , 171 , 178 , 170 )
Performing a simple calculation using vectors:
bmi = weight/ ((height/ 100 )^ 2 )
Creating the matrix:
matrix <- cbind (height, weight, bmi)
Matrices
Visualizing the matrix:
height weight bmi
[1,] 168 88 31.17914
[2,] 177 72 22.98190
[3,] 177 85 27.13141
[4,] 177 52 16.59804
[5,] 178 71 22.40879
[6,] 172 69 23.32342
[7,] 165 61 22.40588
[8,] 171 61 20.86112
[9,] 178 51 16.09645
[10,] 170 75 25.95156
Matrices
Matrices
Matrices
Visualizing the matrix:
height weight bmi
[1,] 168 88 31.17914
[2,] 177 72 22.98190
[3,] 177 85 27.13141
[4,] 177 52 16.59804
[5,] 178 71 22.40879
[6,] 172 69 23.32342
[7,] 165 61 22.40588
[8,] 171 61 20.86112
[9,] 178 51 16.09645
[10,] 170 75 25.95156
Is the new object a matrix?
Matrices
Visualizing the matrix:
height weight bmi
[1,] 168 88 31.17914
[2,] 177 72 22.98190
[3,] 177 85 27.13141
[4,] 177 52 16.59804
[5,] 178 71 22.40879
[6,] 172 69 23.32342
[7,] 165 61 22.40588
[8,] 171 61 20.86112
[9,] 178 51 16.09645
[10,] 170 75 25.95156
How many dimensions does the matrix have?
Matrices
Matrices
Matrices
Dataframes
The matrix we just created can be turned into a dataframe.
Dataframes are essentially lists of vectors with names
#Load the tidyverse tibble package
library (tibble)
mydat <- as_tibble (matrix)
mydat
# A tibble: 10 × 3
height weight bmi
<dbl> <dbl> <dbl>
1 168 88 31.2
2 177 72 23.0
3 177 85 27.1
4 177 52 16.6
5 178 71 22.4
6 172 69 23.3
7 165 61 22.4
8 171 61 20.9
9 178 51 16.1
10 170 75 26.0
Dataframes
Dataframes
Dataframes
#Load the tidyverse tibble package
library (tibble)
mydat <- as_tibble (matrix)
#Seeing the column names
names (mydat)
[1] "height" "weight" "bmi"
Dataframes
Dataframes
Dataframes
Dataframes
Dataframes
Dataframes
Within a dataframe:
Each table row represents an observation, with values possibly of a different type for each variable
Each table column represents a variable, with values of the same type
Dataframes
Dataframes
Dataframes
Dataframes
We can also create a dataframe manually in the following way:
# This is another vector
mydat<- data.frame (
weight = c (88 , 72 , 85 , 52 , 71 , 69 , 61 , 61 , 51 , 75 ),
height = c (168 , 177 , 177 , 177 , 178 , 172 , 165 , 171 , 178 , 170 )
)
mydat
weight height
1 88 168
2 72 177
3 85 177
4 52 177
5 71 178
6 69 172
7 61 165
8 61 171
9 51 178
10 75 170
Dataframes
We can also create a dataframe manually in the following way:
# This is another vector
weight <- c (88 , 72 , 85 , 52 , 71 , 69 , 61 , 61 , 51 , 75 )
height <- c (168 , 177 , 177 , 177 , 178 , 172 , 165 , 171 , 178 , 170 )
mydat<- data.frame (weight, height)
mydat
weight height
1 88 168
2 72 177
3 85 177
4 52 177
5 71 178
6 69 172
7 61 165
8 61 171
9 51 178
10 75 170
Dataframe properties
Some important dataframe properties include:
dim - both the number of rows and columns
rownames - reveals the index numbers of the dataframe
colnames - reveals the column names
Dataframe properties
Here is how they would work
Dataframe properties
Here is how they would work
# This is how we count the number of rows
nrow (mydat)
Dataframe properties
Dataframe properties
Here is how they would work
# This is how we count the number of rows
nrow (mydat)
# This is how we count the number of columns
ncol (mydat)
Dataframe properties
Dataframe properties
Here is how they would work
# This is how we count the number of rows
nrow (mydat)
# This is how we count the number of columns
ncol (mydat)
# This is how we count both the number of rows and number of columns
dim (mydat)
Dataframe properties
Dataframe properties
Here is how they would work
# This is how we count the number of rows
nrow (mydat)
# This is how we count the number of columns
ncol (mydat)
# This is how we count both the number of rows and number of columns
dim (mydat)
# This is how we identify index names
rownames (mydat)
[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"
Dataframe properties
Dataframe properties
Here is how they would work
# This is how we count the number of rows
nrow (mydat)
# This is how we count the number of columns
ncol (mydat)
# This is how we count both the number of rows and number of columns
dim (mydat)
# This is how we identify index names
rownames (mydat)
[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"
# This is how we identify column/variable names
colnames (mydat)
Dataframe properties
Dataframe properties
These properties allow us to also make changes to the dataframe.
For example, we can change column names:
colnames (mydat)[colnames (mydat)== "weight" ]<- "body_weight"
colnames (mydat)
[1] "body_weight" "height"
Dataframe properties
Dataframe properties
The glimpse command from dplyr allows us to see the dataframe effectively.
library (dplyr)
glimpse (mydat)
Rows: 10
Columns: 2
$ body_weight <dbl> 88, 72, 85, 52, 71, 69, 61, 61, 51, 75
$ height <dbl> 168, 177, 177, 177, 178, 172, 165, 171, 178, 170
The $ operator is a shortcut for getting a single column, by name, from a data.frame:
Example:
[1] 168 177 177 177 178 172 165 171 178 170
Dataframe properties
head and tail allow us to see the beginning and the end of our dataframe
For example, the following command gives us the first 4 entries
body_weight height
1 88 168
2 72 177
3 85 177
4 52 177
The following command gives us the last 4 entries
body_weight height
7 61 165
8 61 171
9 51 178
10 75 170
What Have We Learned?
Used Quarto for combining code and narrative
Performed basic arithmetic and assignments in R
Worked with object types : numeric, character, logical
Created and manipulated vectors , matrices , and data frames
Handled missing data with is.na() and na.rm
Used essential functions like mean(), paste(), sort(), rep(), seq()
You now have the foundation to write reproducible scripts and explore real data in R.